import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class Coneccion {
	private Statement coneccion;
    private String url = "jdbc:sqlserver://";
    private String host = "192.168.2.3";
    private String serverName = "DKS02SQLEXP";
    private String portNumber = "65481";
    private String userName;
    private String password;
    private String databaseName = "Polis";
	public Coneccion(String Host, String serverName, String portNumber, String dataBaseName, String userName, String password){
		this.host=Host;
		this.serverName=serverName;
		this.portNumber=portNumber;
		this.databaseName=dataBaseName;
		this.userName=userName;
		this.password=password;
	}
	public EasyScript Conectarse()
	{
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			Connection con = DriverManager.getConnection(url+host+"\\"+serverName+":"+portNumber+";database="+databaseName,userName,password);
			coneccion = con.createStatement();
			System.out.println("Coneccion Establecida");
			return new EasyScript(coneccion);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch (Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}
//	public Resultado Seleccion(String consulta)
//	{
//		Translation t = new Translation(consulta);
//		ResultSet r = null;
//		try{
//			r = coneccion.executeQuery(t.getConsulta());
//		}catch(Exception e)
//		{
//			e.printStackTrace();
//		}
//		Resultado result = new Resultado(r, t.getColumnas());
//		return result;
//	}
//	public void ejecutar(String consulta) {
//		Translation t = new Translation(consulta);
//		try{
//			coneccion.execute(t.getConsulta());
//		}catch(Exception e)
//		{
//			System.out.println("void");
//		}
//	}
}
